#!/bin/bash

tmpfile=$(mktemp)
echo "tmpfile: $tmpfile"

trap "rm -f $tmpfile" exit

while true
do
    date "+%F %T" >> $tmpfile
    sleep 1
done
